#include <iostream>
#include <string>


using namespace std;

class Solution
{
public:
    string makeGood(string s)
    {
        string ret;
        for (auto e : s)
        {
            // (!ret.empty() && tolower(ret.back()) == tolower(ch) && ret.back() != ch)
            if (!ret.empty() && (ret.back() + 32 == e || ret.back() - 32 == e))
            {
                ret.pop_back();
            }
            else
            {
                ret.push_back(e);
            }
        }
        return ret;
    }
};


int main()
{
    Solution xz;
    string s1("QabBAcCv");
    string s2 = xz.makeGood(s1);
    cout << s2 << endl;

	return 0;
}